<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<?
include("../sql/connexionmysql.php");

function getAllMatches($tournamentId) {
	$getAllMatchsSql = 'SELECT * FROM tournamentMatch NATURAL JOIN tournamentField NATURAL JOIN'.
			' tournamentPlayer NATURAL JOIN tournamentRoundType WHERE idTournamentDraw = '.
			$tournamentId .' GROUP BY  (idTournamentMatch)' ;
			$allMatches = mysql_query($getAllMatchsSql);
	return $allMatches;
}

function getNumberOfRound($tournamentId) {
	$getAllMatchsSql = 'SELECT Max(idTournamentRoundType) AS numberOdRound FROM '.
			'tournamentMatch WHERE idTournamentDraw = '.$tournamentId;
	$numberOfRoundQuery = mysql_query($getAllMatchsSql);
	$numberOfRoundQueryArray = mysql_fetch_array ($numberOfRoundQuery);
	return $numberOfRoundQueryArray['numberOdRound'];
}

$tournamentId = $_GET['idTournoi'];
$allMatches = getAllMatches($tournamentId);
$MatchesCount = mysql_num_rows($allMatches);

$numberOfRound = getNumberOfRound($tournamentId);
$heightRound = 50;
$maxMatchPerRound = pow(2, $numberOfRound); 
$maxHeight = $maxMatchPerRound * $heightRound;

	require_once("../phplibrairies/json.php");
	//echo json_encode($nodes);
	$json = new Services_JSON();
	$nodes = Array("test" => "value", 1, Array("test", 1, "test"));
	echo $json->encode($allMatches);

?>

T<?php echo $numberOfRound; ?>P<br/>
ID = <?php echo $tournamentId; ?>

<div id='resultWrapper'>
  
</div>

